package fu.capstone.hanoicityguide.presentation.fragment.holiday;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import fu.capstone.hanoicityguide.R;
import fu.capstone.hanoicityguide.business.bo.holiday.HolidayBO;
import fu.capstone.hanoicityguide.business.bo.holiday.HolidayBOImp;
import fu.capstone.hanoicityguide.business.model.Holiday;
import fu.capstone.hanoicityguide.presentation.adapter.ViewPagerAdapter;

@SuppressLint("ValidFragment")
public class DetailHolidayFragment extends Fragment{

	private HolidayBO holidayBO;
	private int holidayID;
	private ViewPager imgFragment;
	private ViewPagerAdapter vpagerAdapter;
	private TextView holidayDescription;
	
	public DetailHolidayFragment() {

	}

	public DetailHolidayFragment(int holidayID) {
		this.holidayID = holidayID;
	}

	public int getHolidayID() {
		return this.holidayID;
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		

		View browseHolidayFragment = inflater.inflate(
				R.layout.fragment_detail_holiday, container, false);
		
		holidayBO = new HolidayBOImp(container.getContext());
		
		//get data from database
		Holiday holiday = holidayBO.browseHoliday(holidayID);
		
		//fill data into components
		holidayDescription = (TextView) browseHolidayFragment
						.findViewById(R.id.txtHolidayDescription);
		holidayDescription.setText(holiday.getDesc());
		
		imgFragment = (ViewPager) browseHolidayFragment
				.findViewById(R.id.holidayPager);
		vpagerAdapter = new ViewPagerAdapter(getActivity(), holiday.getArrImage());
		imgFragment.setAdapter(vpagerAdapter);
		
		
		return browseHolidayFragment;
	}
	
	
	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		getActivity().getActionBar().setTitle(holidayBO.browseHoliday(holidayID).getName());
	}
	
}
